package org.qy.star_client;

import org.qy.star_common.exception.MQException;
import org.qy.star_common.message.MessageProperties;

import java.io.IOException;
import java.util.ArrayList;

/**
 * @author yinger
 * @description TODO
 * @date 2024/3/31 18:51
 **/
public class Consumer {
    public static void main(String[] args) {
        String ip1 = "127.0.0.1";
        String ip2 = "152.136.59.108";
        Channel channel = Channel.channelFactory(ip1, 7993);
        channel.configMQContext("admin", "admin", "star");
        ArrayList<byte[]> buffer = new ArrayList<>();
        channel.subscribe("testQueue", true, new org.qy.star_common.message.Consumer() {
            int i = 0;
            @Override
            public void handleDelivery(String consumerTag, MessageProperties basicProperties, byte[] body) throws MQException, IOException {
                buffer.add(body);
                System.out.println("received message " + i++);
            }
        });
        while (true) {
        }
    }




}
